1941. Check if All Characters Have Equal Number of Occurrences

Given a string s, return true if s is a good string, or false otherwise.

A string s is good if all the characters that appear in s have the same number of occurrences (i.e., the same frequency).

 

Example 1:

Input: s = "abacbc"
Output: true
Explanation: The characters that appear in s are 'a', 'b', and 'c'. All characters occur 2 times in s.

Example 2:

Input: s = "aaabb"
Output: false
Explanation: The characters that appear in s are 'a' and 'b'.
'a' occurs 3 times while 'b' occurs 2 times, which is not the same number of times.

 

Constraints:

  • 1 <= s.length <= 1000
  • s consists of lowercase English letters.
#1 Two Sum
Easy
#2 Add Two Numbers
Medium
#3 Longest Substring Without Repeating Characters
Medium
#4 Median of Two Sorted Arrays
Hard
#5 Longest Palindromic Substring
Medium
#6 Zigzag Conversion
Medium
#7 Reverse Integer
Medium
#8 String to Integer (atoi)
Medium
#9 Palindrome Number
Easy
#10 Regular Expression Matching
Hard
#11 Container With Most Water
Medium
#12 Integer to Roman
Medium
#13 Roman to Integer
Easy
#14 Longest Common Prefix
Easy
#15 3Sum
Medium
#16 3Sum Closest
Medium
#17 Letter Combinations of a Phone Number
Medium
#18 4Sum
Medium
#19 Remove Nth Node From End of List
Medium
#20 Valid Parentheses
Easy
#21 Merge Two Sorted Lists
Easy
#22 Generate Parentheses
Medium
#23 Merge k Sorted Lists
Hard
#24 Swap Nodes in Pairs
Medium
#25 Reverse Nodes in k-Group
Hard
#26 Remove Duplicates from Sorted Array
Easy
#27 Remove Element
Easy
#28 Find the Index of the First Occurrence in a String
Medium
#29 Divide Two Integers
Medium
#30 Substring with Concatenation of All Words
Hard
#31 Next Permutation
Medium
#32 Longest Valid Parentheses
Hard
#33 Search in Rotated Sorted Array
Medium
#34 Find First and Last Position of Element in Sorted Array
Medium
#35 Search Insert Position
Easy
#36 Valid Sudoku
Medium
#37 Sudoku Solver
Hard
#38 Count and Say
Medium
#39 Combination Sum
Medium
#40 Combination Sum II
Medium
#41 First Missing Positive
Hard
#42 Trapping Rain Water
Hard
#43 Multiply Strings
Medium
#44 Wildcard Matching
Hard
#45 Jump Game II
Medium
#46 Permutations
Medium
#47 Permutations II
Medium
#48 Rotate Image
Medium
#49 Group Anagrams
Medium
#50 Pow(x, n)
Medium